<template>
  <dw-tree ref="templateFileTreeRef" :getTreeUrl="getTreeUrl" :addTreeUrl="addTreeUrl" :editTreeUrl="editTreeUrl" :delTreeUrl="delTreeUrl" :treeProps="treeProps" @nodeClick="nodeClick">
    <template #icon="{ data }">
      <el-icon v-if="data.directory === 1"><Folder /></el-icon>
      <el-icon v-if="data.directory === 0"><Document /></el-icon>
    </template>
  </dw-tree>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import type { ITemplateFileTree } from '../template-set';
const templateFileTreeRef = ref();
const getTreeUrl: string = '/admin-api/gen/template/file/tree/vvKqaL7gyMUq-faF9HeLm';
const addTreeUrl: string = '/admin-api/gen/template/file';
const editTreeUrl: string = '/admin-api/gen/template/file';
const delTreeUrl: string = '/admin-api/gen/template/file/{id}';
const treeProps = { label: 'fileName', children: 'children', total: 'totalNum' };
const currentNodeData = ref<ITemplateFileTree | undefined>();
const emits = defineEmits(['currentNodeChange']);
const nodeClick = (data: ITemplateFileTree) => {
  currentNodeData.value = data;
  emits('currentNodeChange', currentNodeData.value);
};
</script>
